import request from '@/utils/request';
import moment from 'moment'
import {fixedZero} from '@/utils/utils';

export async function query({...resetParams}) {
  return request(`/revenue_overview`,{
    method:'GET',
    params:{
      ...resetParams
    }
  });
}

export async function queryPress({...resetParams}) {
  return request(`/pressure_sensors`,{
    method:'GET',
    params:{
      ...resetParams
    }
  });
}
export async function queryWorkstations({...resetParams}) {
  return request(`/all_workstations`,{
    method:'GET',
    params:{
      ...resetParams,
      template:1,
      order_direction:'desc'
    }
  });
}

export async function queryRevenue({...resetParams}) {
  return request(`/revenue_overview`,{
    method:'GET',
    params:{
      days:30
    }
  });
}

export async function queryMeter({...resetParams}) {
  return request(`/meter_overview`,{
    method:'GET',
    params:{
      days:30
    }
  });
}

export async function queryWaterworks({...resetParams}) {
  return request(`/waterworks_device_latest_data`,{
    method:'GET',
    params:{
      ...resetParams
    }
  });
}

export async function queryWaterworksHistory({...resetParams}) {
  return request(`/waterworks_device_historical_data`,{
    method:'GET',
    params:{
      items:['item4','item8','item10'],
      start_time:`${(new Date()).getFullYear()}-${fixedZero((new Date()).getMonth()+1)}-${fixedZero((new Date()).getDate())} 00:00:00`,
      end_time:moment(new Date()).format('YYYY-MM-DD HH:mm:ss'),
      ...resetParams
    }
  });
}

